<template>
    <div class="pwdCheckCard">
      <el-form>
        <br>
        <el-form-item>
        <el-input placeholder="请输入旧密码" v-model="userOldPassword" show-password/>
        </el-form-item>
        <br>
        <el-form-item>
        <el-button @click="onSubmit()" type="primary" >提交</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
export default {
  name: 'passwordCheck',
  data () {
    return {
      userOldPassword: '',
      isOk: false
    }
  },
  mounted () {
    this.userId = this.$route.params.id
  },
  methods: {
    onSubmit () {
      if (this.userOldPassword !== '') {
        this.$axios({
          methods: 'post',
          url: '/user/checkPwd',
          headers: { 'content-type': 'application/x-www-form-urlencoded' },
          params: {
            userId: this.userId,
            userPwd: this.userOldPassword
          }
        })
          .then((response) => {
            console.log(response)
            if (response.data.data === true) {
              this.$router.push('/ResetPassword/' + this.userId)
            } else {
              alert(response.data.msg)
            }
          })
          .catch(function (error) { console.log(error) })
      } else {
        alert('密码不能为空')
      }
    }
  }
}
</script>

<style scoped>
.pwdCheckCard {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    /* transition: 0.3s; */
    width: 80%;
    border-radius: 5px;
    float:left;
    height: 100%;
    /* margin-top: 5%;
    margin-left: 5%; */
    background-color: #fff;
}

.el-form{
    width:80%;
    margin: auto;
    height:20%;
}

.el-input{
  width: 50%;
}

.el-button{
    width: 20%;
}
</style>
